package com.fuxue.controller.server;

import com.fuxue.dto.TitleDTO;
import com.fuxue.entity.Title;
import com.fuxue.result.Result;
import com.fuxue.service.TitleService;
import com.fuxue.vo.TitleVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/users/server/title")
@Slf4j
@Api(tags = "服务者相关接口")
public class TitleController {

       @Autowired
       private TitleService titleService;

       @GetMapping("/{id}")
       private Result<TitleVO>getById(@PathVariable Integer id)
       {
           System.out.println(id);
           log.info("服务者的id，参数为{}",id);
           TitleVO titleVO = titleService.getById(id);

           return Result.success(titleVO);
       }
       @GetMapping("/show")
       private Result<List<Title>>getAll(String select)
       {
           log.info("进行查询全部内容");
           List<Title>list = new ArrayList<Title>();
           list = titleService.getAll(select);


           return Result.success(list);
       }
       @PutMapping("/update")
       private Result update(@RequestBody TitleDTO titleDTO)
       {
           log.info("更新服务者的数据，参数为{}",titleDTO);
           titleService.update(titleDTO);
           return Result.success();
       }

}
